<template>
    <el-dialog v-if="dialogVisible" :close-on-click-modal='false' title="关联广告组/广告账户" :visible.sync="dialogVisible" @close="resetForm()" width="932px">
        <div class="adver_main flexbox flexcenter" v-loading="loading" element-loading-spinner="el-icon-loading" element-loading-background="rgba(0, 0, 0, 0)">
            <div class="table_width">
                <div class="adv_head">
                    <div class="flexbox flexcenter flexbetween">
                        <span class="font_16 color_01">已添加广告组</span>
                    </div>
                </div>
                <div class="adv_table">
                    <el-table :data="tableData" class="com_table" height="400px" ref="planRef">
                        <div slot="empty" class="flexbox flexcenter flexcolumn flexjust" style="height:400px">
                            <img src="../../assets/img/null_icon.svg" alt="">
                            <div class="font_13 color_03">暂无数据，请添加广告组</div>
                        </div>
                        <el-table-column prop="campaign_id" label="广告组信息">
                            <template slot-scope="scope">
                                <div class="adv_name">{{scope.row.name}}</div>
                                <div class="adv_id">{{scope.row.campaign_id}}</div>
                            </template>
                        </el-table-column>
                    </el-table>
                </div>
            </div>
            <div class="table_width">
                <div class="adv_head">
                    <div class="flexbox flexcenter flexbetween">
                        <span class="font_16 color_01">已添加广告账户</span>
                    </div>
                </div>
                <div class="adv_table">
                    <el-table :data="userData" class="com_table" height="400px" ref="userTable">
                        <div slot="empty" class="flexbox flexcenter flexcolumn flexjust" style="height:400px">
                            <img src="../../assets/img/null_icon.svg" alt="">
                            <div class="font_13 color_03">暂无数据，请添加广告账户</div>
                        </div>
                        <el-table-column prop="id" label="广告账户信息">
                            <template slot-scope="scope">
                                <div class="adv_name">{{scope.row.name}}</div>
                                <div class="adv_id">{{scope.row.id}}</div>
                            </template>
                        </el-table-column>
                        <el-table-column prop="type" label="类型" width="110">
                            <template slot-scope="scope">
                                <div class="adv_name" v-for="item in scope.row.type" :key="item">{{item==1?"直播托管":"短视频托管"}}</div>
                            </template>
                        </el-table-column>
                    </el-table>
                </div>
            </div>
        </div>
    </el-dialog>
</template>

<script>
export default {
    name: "",
    data() {
        return {
            loading: false,
            dialogVisible: false,
            queryInfo: {
                template_id: "",
            },
            tableData: [],
            userData:[],
        };
    },
    created() {
        this.$bus.on("viewPlanGroup", (value) => {
            this.dialogVisible = value.dialogVsb;
            this.queryInfo.template_id = value.template_id;
            this.getDataList();
        });
    },
    beforeDestroy() {
        this.$bus.off("viewPlanGroup");
    },
    methods: {
        //获取广告组
        async getDataList() {
            this.loading = true
            const { data: res } = await this.$http.post(
                "autodrop/configure/templateCampaign",
                this.queryInfo
            );
            if (res.code !== 200) {
                this.loading = false
                this.$message.error(res.msg);
                return;
            } else {
                this.loading = false
                this.tableData = res.data.campaign_group_id;
                this.userData = res.data.advertiser_id;
            }
        },

        // 关闭重置表单
        resetForm() {
            this.dialogVisible = false;
        },
    },
    components: {},
};
</script>


<style scoped>
.table_width{
    width: 50%;
}
.hascheck_box{
    height: 30px;
    border: 1px solid #4475ff;
    background: #f6f8ff;
    padding: 0 20px;
    border-radius: 4px;
    font-size: 14px;
    color: #616c85;
}
.has_close{
    cursor: pointer;
    padding: 3px;
    border-radius: 2px;
}
.has_close:hover{
    background: #eeeff0
}
.adver_main{
    margin: -20px;
    position: relative;
}
.adver_main::after{
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    z-index: 2;
    border-left: 1px solid #EBEBEB;
}
.adv_head{
    padding: 20px;
    border-bottom: 1px solid #EBEBEB
}
.adv_table{
    padding: 20px;
}
.adv_name{
    font-size: 14px;
    color: #616C85;
}
.adv_id{
    font-size: 14px;
    color: #B4B7BD;
    margin-top: 4px;
}
</style>
